<template>
  <div class="comments">
    <div class="list" v-for="item in list" :key="item.id">
      <div class="userInfo">
        <div class="info">
          <div class="avatar">
            <img :src="item.user_photo" />
          </div>
          <div class="name">{{item.nickname}}</div>
          <van-rate v-model="item.goods_score" icon="rate-yellow" void-icon="rate-gray" readonly />
        </div>
        <div class="time">{{item.create_time | formatDate('YYYY-MM-DD')}}</div>
      </div>
      <div class="content">
        {{item.content}}
      </div>
      <div class="images">
        <template v-for="(img, index) in item.ImgList">
          <div class="img" :key="'contractImg_' + index">
            <img @click="imagePreview(index,item)" :src="img" width="100%" />
          </div>
        </template>
        <span class="img_total">共{{item.ImgList?item.ImgList.length:0}}张图</span>
      </div>
      <div class="size">{{item.goods_spec_names}}</div>
    </div>
  </div>
</template>
<script>
import { ImagePreview } from 'vant';
export default {
  name: 'Comments',
  data () {
    return {
      rateValue: 4
    };
  },
  props: {
    cateItem: {
      type: Array
    },
    list: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    imagePreview (index, item) {
      ImagePreview({
        images: item.ImgList,
        startPosition: index,
        closeable: true,
        className: this.isApp ? 'isApp' : ''
      });
    }
  }
};
</script>
<style scoped lang="less">
.comments {
  padding: 0 18px;
  .list {
    padding: 30px 0;
    overflow: hidden;
    margin: 0 18px;
    border-top: 1px solid #eee; /*no*/
    .userInfo {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 0 10px 0;
      .info {
        display: flex;
        align-items: center;
        .avatar {
          width: 60px;
          height: 60px;
          border-radius: 60px;
          background-color: #eee;
          img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }
        .name {
          font-size: 30px;
          color: #353535;
          margin: 0 20px;
        }
      }
      .time {
        color: #969aa6;
        font-size: 24px;
      }
    }
    .content {
      padding: 10px 0;
      font-size: 28px;
      color: #353535;
      line-height: 44px;
    }
    .images {
      overflow: hidden;
      padding-bottom: 20px;
      display: flex;
      position: relative;
      flex-wrap: wrap;
      .img {
        height: 160px;
        background-color: #fff;
        margin-right: 12px;
        margin-bottom: 12px;
        img {
          width: 160px;
          height: 160px;
        }
        &:nth-child(4n) {
          margin-right: 0;
        }
      }
      .img_total {
        color: #fff;
        position: absolute;
        bottom: 20px;
        right: 4px;
        padding: 10px 20px;
        font-size: 24px;
        background-color: rgba(255, 0, 52, 0.8);
      }
    }
    .size {
      color: #959595;
      font-size: 24px;
      padding: 5px 0;
    }
  }
  .list:first-child {
    border-top: none;
  }
}
</style>
